//
//  TopicDetailViewController.m
//  DebugDemo
//
//  Created by XFB on 2019/1/2.
//  Copyright © 2019年 ZhouCheng. All rights reserved.
//

#import "TopicDetailViewController.h"
#import "ZCBaseScrollView.h"

@interface TopicDetailViewController () <UIScrollViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate>

@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) UICollectionViewFlowLayout *flowLayout;
@property (nonatomic, strong) ZCBaseScrollView *scrollViewBG;

@end

@implementation TopicDetailViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setupBasicSet];
    [self setupUI];
}

- (void)setupBasicSet
{
    self.view.backgroundColor = [UIColor whiteColor];
}

- (void)setupUI
{
    [self.view addSubview:self.scrollViewBG];

    /// collectionView
    self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
    self.flowLayout.itemSize = CGSizeMake(ScreenW, ScreenH-NavBarHeight-BottomHeight);
    self.flowLayout.minimumLineSpacing = 0.0f;
    self.flowLayout.minimumInteritemSpacing = 0.0f;
    self.flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 100, ScreenW, ScreenH-NavBarHeight-BottomHeight) collectionViewLayout:self.flowLayout];
    self.collectionView.backgroundColor = [UIColor lightGrayColor];
    self.collectionView.pagingEnabled = YES;
    self.collectionView.dataSource = self;
    self.collectionView.delegate = self;
    [self.scrollViewBG addSubview:self.collectionView];
    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor colorWithRed:(arc4random()%255)/255.0f green:(arc4random()%255)/255.0f blue:(arc4random()%255)/255.0f alpha:1];
    return cell;
}

#pragma mark --- <UIScrollViewDelegate>
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    
}


#pragma mark --- <Lazy loading>

- (UIScrollView *)scrollViewBG
{
    if (nil == _scrollViewBG) {
        _scrollViewBG = [[ZCBaseScrollView alloc] initWithFrame:CGRectMake(0, NavBarHeight, ScreenW, ScreenH-NavBarHeight-BottomHeight)];
        _scrollViewBG.delegate = self;
        _scrollViewBG.backgroundColor = [UIColor orangeColor];
        _scrollViewBG.contentSize = CGSizeMake(ScreenW, ScreenH);
    }
    return _scrollViewBG;
}

@end
